package me.project.jobster.common.util;


/**
 * @author mbryce
 */
public class Response {
    private boolean isSuccess;
    private String respCode;
    private String respMessage;
    private Object result;

    /**
     * fail response
     *
     * @param respCode fail code
     * @param respMsg  fail msg
     * @return
     */
    public static Response getInstance(String respCode, String respMsg) {
        Response response = new Response();
        response.setSuccess(false);
        response.setRespCode(respCode);
        response.setRespMessage(respMsg);
        return response;
    }

    /**
     *
     * @param isSuccess
     * @param respCode
     * @param respMsg
     * @param result
     * @return
     */
    public static Response getInstance(boolean isSuccess, String respCode, String respMsg, Object result) {
        Response response = new Response();
        response.setSuccess(isSuccess);
        response.setRespCode(respCode);
        response.setRespMessage(respMsg);
        response.setResult(result);
        return response;
    }

    /**
     * success
     *
     * @param result
     * @return
     */
    public static Response getInstance(Object result) {
        Response response = new Response();
        response.setSuccess(true);
        response.setResult(result);
        return response;
    }

    public boolean isSuccess() {
        return isSuccess;
    }

    public void setSuccess(boolean isSuccess) {
        this.isSuccess = isSuccess;
    }

    public String getRespCode() {
        return respCode;
    }

    public void setRespCode(String respCode) {
        this.respCode = respCode;
    }

    public String getRespMessage() {
        return respMessage;
    }

    public void setRespMessage(String respMessage) {
        this.respMessage = respMessage;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    @Override
    public String toString() {
        return "Response{" +
                "isSuccess=" + isSuccess +
                ", respCode='" + respCode + '\'' +
                ", respMessage='" + respMessage + '\'' +
                ", result=" + result +
                '}';
    }
}
